/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.patpro.controladores;

import com.patpro.modelo.javabeans.Curso;
import com.patpro.modelo.servicios.CursoService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**

 */
public class EliminaCursoController extends AbstractController {

    private CursoService servicio_curso;

    public CursoService getServicio_curso() {
        return servicio_curso;
    }

    public void setServicio_curso(CursoService servicio_curso) {
        this.servicio_curso = servicio_curso;
    }

    public EliminaCursoController() {
    }

    protected ModelAndView handleRequestInternal(
            HttpServletRequest request,HttpServletResponse response) throws Exception {
        ModelAndView mv = null;
        String id_curso = request.getParameter("id");
        int resp = servicio_curso.eliminarCurso(new Curso(Integer.parseInt(id_curso)));
        if(resp > 0)
            mv = new ModelAndView("exito");
        else
            mv = new ModelAndView("error");
        mv.addObject("controlador", "adminCurso");
        return mv;
    }
}
